//
//  AppDelegate.m
//  Systetagram
//
//  Created by 欧杨 on 2020/12/22.
//

#import <Photos/Photos.h>
#import "AppDelegate.h"
#import "HomeViewController.h"
#import "ImageViewController.h"
#import "ProfileViewController.h"
#import "ViewController.h"
#import "Login.h"

@interface AppDelegate ()<UITabBarControllerDelegate>

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
//    self.urls = [NSMutableArray arrayWithObjects:
//             [NSURL URLWithString:@"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201711%2F11%2F20171111174756_GdwSf.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1611934802&t=e8f7bb9893efea7418a93aea13064b40"],
//             [NSURL URLWithString:@"https://hbimg.huabanimg.com/6215ba6f9b4d53d567795be94a90289c0151ce73400a7-V2tZw8_fw658"],
//             [NSURL URLWithString:@"https://hbimg.huabanimg.com/834ccefee93d52a3a2694535d6aadc4bfba110cb55657-mDbhv8_fw658"],
//             [NSURL URLWithString:@"https://hbimg.huabanimg.com/f3085171af2a2993a446fe9c2339f6b2b89bc45f4e79d-LacPMl_fw658"],
//             [NSURL URLWithString:@"https://hbimg.huabanimg.com/e5c11e316e90656dd3164cb97de6f1840bdcc2671bdc4-vwCOou_fw658"],nil];
//
//    self.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:self.urls[0]]];
//
//    NSString *str = [[NSString alloc] init];
//    NSNumber *boolNum = [NSNumber numberWithBool:YES];
//    BOOL boolValue = [boolNum boolValue];
//
//    ViewController *VC1 = [[ViewController alloc] init];
//    ViewController *VC2 = [[ViewController alloc] init];
//    [VC1 setTitle:@"VC1"];
//    [VC2 setTitle:@"VC2"];
//    UITabBarController *tab = [[UITabBarController alloc] init];
//    //UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:VC];
//    tab.viewControllers = @[VC1, VC2];
//    self.userID  = @2;
//    self.token = @"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTI1MDU4NDIsImlhdCI6MTYwOTkxMzg0MiwianRpIjoiZDY0NWU5NGQtNGZlNi0xMWViLWE2MzAtMDAxNjNlMGMyYzY3Iiwic3ViIjoiYSJ9.28u1g-bq8A4QmeMw7vhylguRM9GroLhuhqMwrxbDa6E";
    
//    for (int i=1; i<=7; i++) {
//        PHPhotoLibrary *library = [PHPhotoLibrary sharedPhotoLibrary];
//        [library performChanges:^{
//            [PHAssetChangeRequest creationRequestForAssetFromImage:[UIImage imageNamed:[NSString stringWithFormat:@"%d", i]]];
//        } completionHandler:^(BOOL success, NSError * _Nullable error) {
//            ;
//        }];
//    }
    
    
    self.window = [[UIWindow alloc] init];
    self.window.backgroundColor = UIColor.systemBackgroundColor;
    self.window.rootViewController = [[Login alloc] init];
    [self.window makeKeyAndVisible];
    
    return YES;
}

- (UITabBarController *)tab
{
    if (!_tab) {
        _tab = [[UITabBarController alloc] init];
        UINavigationController *homeNav = [[UINavigationController alloc] initWithRootViewController:[[HomeViewController alloc] init]];
        UINavigationController *publishNav = [[UINavigationController alloc] initWithRootViewController:[[ProfileViewController alloc] init]];
        _tab.viewControllers = @[homeNav, publishNav];
        _tab.tabBar.tintColor = UIColor.redColor;
    }
    return _tab;
}

//- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
//{
//    if (viewController == _tab.viewControllers[0] || viewController == _tab.viewControllers[1]) {
//        if (!_isLogin) {
//            return NO;
//        }
//    }
//    return YES;
//}

@end
